<?php

if (!defined('TOBBIVM'))
	header('location:/template/notrepassing.php');
/**
 * This file is part of TobbiVMShop.
 *
 * TobbiVMShop is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * TobbiVMShop is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with TobbiVMShop.  If not, see <http://www.gnu.org/licenses/>.
 */
/**
 * Copy one article incl. values
 * used from article.page.php
 * 
 * @version    $Id$
 * @package    TobbiVM-Shop
 * @copyright  Copyright (C) 2012
 * @author     Norbert Gebert
 * @license    GPL3
 */
foreach ($_POST['marker'] as $idx)
{
	db::getInstance()->where('product_id', $idx);
	$ordernr = db::getInstance()->getOne('product');

	db::getInstance()->where('product_category', $ordernr['product_category']);
	$count = db::getInstance()->get('product');

	$countx = db::getInstance()->rawQuery("SELECT count(*) FROM product " .
		"WHERE product_category ='" . $ordernr['product_category'] . "'");
	$count = $countx[0]['count(*)'] + 1;

	db::getInstance()->rawQuery("CREATE TEMPORARY TABLE tmp SELECT * FROM product WHERE " .
		"product_id = '" . $idx . "'");

	$data = Array(
	 'product_id' => NULL,
	 'product_order' => $count,
	 'product_image' => '',
	 'product_small_image' => '');
	db::getInstance()->update('tmp', $data);

	db::getInstance()->rawQuery("INSERT INTO product SELECT * FROM tmp");

	$idy = db::getInstance()->rawQuery("SELECT LAST_INSERT_ID()");
	
	$_GET['id'] = $idy[0]['LAST_INSERT_ID()'];
	$idx = $_GET['id'];
	break;
}
?>
